<p style="color:#555;padding-left: 1em;">如果添加的内容已存在，将被忽略</p>
<form id="editServiceType" method="post">
    <div style="width:95%;">
        <div class="field">
            <label for="serv_type">服务类型：</label>
        </div>
        <div class="fieldContent">
            <input id="serv_type" class="easyui-combobox" name="serv_type" required style="width: 80%"/>
        </div>
        <div class="field">
            <label for="serv_name">服务名称：</label>
        </div>
        <div class="fieldContent">
            <input id="serv_name" class="easyui-combobox" name="serv_name" required style="width: 80%"/>
        </div>
        <div class="field">
            <label for="describe">描述信息（选填）：</label>
        </div>
        <div class="fieldContent">
            <input id="describe" class="easyui-textbox" name="describe"  style="width: 80%"/>
        </div>
    </div>
</form>
<script>
    var sts, names={}, types=[];
    $('#serv_type').combobox({
        editable:false,
        onSelect:function(rec){
            $('#serv_name').combobox('loadData', names[rec.value]);
        }
    })
    $('#serv_name').combobox({
    })
    $.ajax({
        url:'/lifeService/getServiceTypeList',
        type:'get',
        success:function(data, status){
            sts = data;
            handleTypes();
            //$('#serv_type').combobox({data:[]});
            $('#serv_type').combobox('loadData',types);
        }
    })
    function handleTypes(){
        var flags = {};
        var ii;
        var i;
        for(ii in sts){
            i = sts[ii];
            if(!flags[i.serv_type]){
                flags[i.serv_type] = true;
                types.push({value:i.serv_type, text:i.serv_type});
                //types.push(i.serv_type);
                names[i.serv_type] = [{value:i.serv_name,text:i.serv_name}];
            }else{
                names[i.serv_type].push({value:i.serv_name,text:i.serv_name});
            }
        }
    }
    function show(){
        alert($('#serv_name').combobox('getText'))
    }
</script>